/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dp1.titandevelop.titano.view.almac;

import dp1.titandevelop.titano.bean.Estado;
import dp1.titandevelop.titano.bean.Mensajes;
import dp1.titandevelop.titano.persistent.Almacen;
import dp1.titandevelop.titano.persistent.Producto;
import dp1.titandevelop.titano.service.AlmacenService;
import dp1.titandevelop.titano.service.ProductoService;
import dp1.titandevelop.titano.service.ValidacionService;
import dp1.titandevelop.titano.view.LoginT;
import java.awt.Cursor;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Yulian
 */
public class ModulosT_ALM_AdmAlm extends javax.swing.JInternalFrame {

    public List<Almacen> almacenes;
    
    private Mensajes sms = new Mensajes();
    //Para el manejo del cbox
    public List<Producto> productos;
    
    private void addList (List<Producto> lista){
        
        for(int i=0;i<lista.size();i++){
            this.cboxProducto.addItem(lista.get(i).getDescripcion());
        }
    }
    public void RefreshTable() {
        AbstractTableModel aux = (AbstractTableModel)tblResultadosAlmacen.getModel();
        aux.fireTableDataChanged();
    }
    public void habilitaBotones(){
        this.btnEditarA.setEnabled(true);
        this.btnEliminarA.setEnabled(true);
        this.btnDetalle.setEnabled(true);
    }
    private void inhabilitaBotones(){
        this.btnEditarA.setEnabled(false);
        this.btnEliminarA.setEnabled(false);
        this.btnDetalle.setEnabled(false);
    }
    
    private AbstractTableModel modeloTabla = new AbstractTableModel() {  
        
        @Override
        public int getRowCount() {
            return almacenes.size(); // cuantos registros (filas)
        }      
        
        @Override
        public int getColumnCount() {
            return 3; // cuantas columnas
        }  
        
        String [] titles = {"Almacén", "Dirección", "Estado"};
        
        @Override
        public String getColumnName(int col){
            return titles[col];
        }        
          
        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            String res=null;
            Almacen p = almacenes.get(rowIndex);
            switch(columnIndex){
                case 0: res = p.getDescripcion(); break;
                case 1: res = p.getDireccion();break;
                case 2: res = Estado.devuelveCadena(p.getEstado());
            }
            return res;
        }  
    };
    
    public ModulosT_ALM_AdmAlm() {
        initComponents();
        Estado state = new Estado();
        this.almacenes=new ArrayList<Almacen>();
        this.tblResultadosAlmacen.setModel(modeloTabla);
        inhabilitaBotones();
        
        this.cboxEstado.addItem(state.getSinUsarEnUso().get(0));
        this.cboxEstado.addItem(state.getSinUsarEnUso().get(1));       
        
       ProductoService serv = new ProductoService();
       productos = serv.buscar();
       addList(productos);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        cboxEstado = new javax.swing.JComboBox();
        txtDescripcion = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        cboxProducto = new javax.swing.JComboBox();
        txtDireccion = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblResultadosAlmacen = new javax.swing.JTable();
        btnBuscar = new javax.swing.JButton();
        btnNuevo = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();
        btnEliminarA = new javax.swing.JButton();
        btnEditarA = new javax.swing.JButton();
        btnDetalle = new javax.swing.JButton();
        btnCargaMasiva = new javax.swing.JButton();

        setResizable(true);
        setTitle("Administración de Almacenes");

        jPanel1.setToolTipText("");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Filtros de Búsqueda"));

        jLabel1.setText("Descripción");

        jLabel2.setText("Estado");

        cboxEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccionar" }));
        cboxEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboxEstadoActionPerformed(evt);
            }
        });

        jLabel3.setText("Dirección");

        jLabel4.setText("Producto");

        cboxProducto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccionar" }));
        cboxProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboxProductoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(17, 17, 17)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3))
                .addGap(17, 17, 17)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cboxProducto, 0, 156, Short.MAX_VALUE)
                    .addComponent(txtDireccion))
                .addGap(8, 8, 8))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(cboxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(cboxProducto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados de Búsqueda"));

        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        tblResultadosAlmacen.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Almacén", "Dirección", "Estado"
            }
        ));
        tblResultadosAlmacen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblResultadosAlmacenMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblResultadosAlmacen);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
                .addGap(8, 8, 8))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
        );

        btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/buscar.png"))); // NOI18N
        btnBuscar.setToolTipText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/nuevo.png"))); // NOI18N
        btnNuevo.setToolTipText("Nuevo");
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        btnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/limpiar.png"))); // NOI18N
        btnLimpiar.setToolTipText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });

        btnSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/retroceder.png"))); // NOI18N
        btnSalir.setToolTipText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        btnEliminarA.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/eliminar.png"))); // NOI18N
        btnEliminarA.setToolTipText("Eliminar");
        btnEliminarA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarAActionPerformed(evt);
            }
        });

        btnEditarA.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/editar.png"))); // NOI18N
        btnEditarA.setToolTipText("Editar");
        btnEditarA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarAActionPerformed(evt);
            }
        });

        btnDetalle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/detalle.png"))); // NOI18N
        btnDetalle.setToolTipText("Ver Detalle");
        btnDetalle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDetalleActionPerformed(evt);
            }
        });

        btnCargaMasiva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/texto.png"))); // NOI18N
        btnCargaMasiva.setToolTipText("Carga Masiva");
        btnCargaMasiva.setActionCommand("masivo");
        btnCargaMasiva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCargaMasivaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(btnNuevo)
                        .addGap(1, 1, 1)
                        .addComponent(btnLimpiar)
                        .addGap(1, 1, 1)
                        .addComponent(btnCargaMasiva)
                        .addGap(0, 0, 0)
                        .addComponent(btnSalir)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(btnDetalle)
                                .addGap(1, 1, 1)
                                .addComponent(btnEditarA)
                                .addGap(1, 1, 1)
                                .addComponent(btnEliminarA)))
                        .addGap(8, 8, 8))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnBuscar)
                    .addComponent(btnNuevo)
                    .addComponent(btnLimpiar)
                    .addComponent(btnSalir)
                    .addComponent(btnCargaMasiva, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnEliminarA, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnDetalle, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnEditarA, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(8, 8, 8))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 17, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cboxProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboxProductoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cboxProductoActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
        //ID 19 Nuevo Almacen

        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (19 == (Integer) LoginT.idspermisosxperfil.get(i)) {
                 ModulosT_ALM.ventanaNuevo = new ModulosT_ALM_AlmNuevo();
        this.getParent().add(ModulosT_ALM.ventanaNuevo);        
        Dimension desktopSize = this.getParent().getSize();
        Dimension jInternalFrameSize = ModulosT_ALM.ventanaNuevo.getSize();
        ModulosT_ALM.ventanaNuevo.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                (desktopSize.height - jInternalFrameSize.height)/4 );
        ModulosT_ALM.ventanaNuevo.show();        
        this.dispose();
        break;
            }
            }
        
         if (i >= LoginT.permisosxperfil.size()) {
            JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                    "No posee permisos",
                    JOptionPane.WARNING_MESSAGE);
        }
       
        
        
        
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnSalirActionPerformed

    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
       txtDescripcion.setText("");
       cboxEstado.setSelectedIndex(0);
       txtDireccion.setText("");
       cboxProducto.setSelectedIndex(0);
       almacenes.clear();
       this.RefreshTable();
       this.inhabilitaBotones();
    }//GEN-LAST:event_btnLimpiarActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        AlmacenService serv = new AlmacenService();
        ValidacionService val = new ValidacionService();
        
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (val.esCBoxVacio(cboxEstado)&&val.esCBoxVacio(cboxProducto)){
            almacenes = serv.buscarFiltrado(this.txtDescripcion.getText(),this.txtDireccion.getText());
        }
        else {
            int id=0;
            int idEstado = -1;
            if (!val.esCBoxVacio(cboxProducto))
            id = productos.get(this.cboxProducto.getSelectedIndex()-1).getIdproducto();
            if (!val.esCBoxVacio(cboxEstado))
                idEstado = Estado.getEstadoId(cboxEstado.getSelectedItem().toString());
            
            almacenes = serv.buscarFiltrado(this.txtDescripcion.getText(),this.txtDireccion.getText(),id,idEstado);
        
        }
        this.setCursor(Cursor.getDefaultCursor());
        
        this.RefreshTable();
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnEliminarAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarAActionPerformed
    //ID 20 Nuevo Almacen

        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (20 == (Integer) LoginT.idspermisosxperfil.get(i)) {
                
                 
        int confirmar = JOptionPane.showInternalConfirmDialog(this.getRootPane(),sms.getPregEliminar(),"Aviso!",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE);

        if (JOptionPane.OK_OPTION == confirmar)
        {//Obtengo el objeto seleccionado
            AlmacenService serv = new AlmacenService();
            int idAlm =this.almacenes.get(this.tblResultadosAlmacen.getSelectedRow()).getIdalmacen();
            int op = serv.eliminar(idAlm);
            if(op!=1){
                if(op==2)
                    JOptionPane.showInternalConfirmDialog(this.getRootPane(),"No se puede eliminar un almacén temporal","Aviso!",JOptionPane.CLOSED_OPTION,JOptionPane.WARNING_MESSAGE);
                else
                    JOptionPane.showInternalConfirmDialog(this.getRootPane(),sms.getNoEliminadoPorUso(),"Aviso!",JOptionPane.CLOSED_OPTION,JOptionPane.WARNING_MESSAGE);
            }
            else{
                this.almacenes.remove(this.tblResultadosAlmacen.getSelectedRow()); 
            }
        }

        this.RefreshTable();
        this.inhabilitaBotones();
        break;
            }
        }
        
            if (i >= LoginT.permisosxperfil.size()) {
            JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                    "No posee permisos",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_btnEliminarAActionPerformed

    private void btnEditarAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarAActionPerformed
 //ID 20 Nuevo Almacen

        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (20 == (Integer) LoginT.idspermisosxperfil.get(i)) {
        
        //Obtengo el objeto seleccionado
        Almacen alm;
        alm = almacenes.get(this.tblResultadosAlmacen.getSelectedRow());
        
        //Instancio la ventana
        ModulosT_ALM.ventanaEdita = new ModulosT_ALM_AlmEdita(alm);
        this.getParent().add(ModulosT_ALM.ventanaEdita);

        Dimension desktopSize = this.getParent().getSize();
        Dimension jInternalFrameSize = ModulosT_ALM.ventanaEdita.getSize();
        ModulosT_ALM.ventanaEdita.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,(desktopSize.height - jInternalFrameSize.height)/4 );
        ModulosT_ALM.ventanaEdita.show();

        //Inhabilito los botones una vez realizada la acción
        this.inhabilitaBotones();
        break;
            }
        }
        
        if (i >= LoginT.permisosxperfil.size()) {
            JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                    "No posee permisos",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_btnEditarAActionPerformed

    private void cboxEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboxEstadoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cboxEstadoActionPerformed

    private void tblResultadosAlmacenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblResultadosAlmacenMouseClicked
        if(evt.getClickCount()==1){
            this.habilitaBotones();
        }
    }//GEN-LAST:event_tblResultadosAlmacenMouseClicked

    private void btnDetalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDetalleActionPerformed
        //Obtengo el objeto seleccionado
        Almacen alm;
        alm = almacenes.get(this.tblResultadosAlmacen.getSelectedRow());
        //Instancio la ventana
        
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        ModulosT_ALM_AlmDetalle ventanaDetalle = new ModulosT_ALM_AlmDetalle(alm.getIdalmacen());
        this.getParent().add(ventanaDetalle);

        Dimension desktopSize = this.getParent().getSize();
        Dimension jInternalFrameSize = ventanaDetalle.getSize();
        ventanaDetalle.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,(desktopSize.height - jInternalFrameSize.height)/4 );
        this.setCursor(Cursor.getDefaultCursor());
        
        ventanaDetalle.show();

        //Inhabilito los botones una vez realizada la acción
        this.inhabilitaBotones();
    }//GEN-LAST:event_btnDetalleActionPerformed

    private void btnCargaMasivaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCargaMasivaActionPerformed
        Carga_Masiva_Alm cargaMasiva = new Carga_Masiva_Alm();
        this.getParent().add(cargaMasiva);
        Dimension desktopSize = this.getParent().getSize();
        Dimension jInternalFrameSize = cargaMasiva.getSize();
        cargaMasiva.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
            (desktopSize.height - jInternalFrameSize.height) / 4);
        cargaMasiva.show();
    }//GEN-LAST:event_btnCargaMasivaActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnCargaMasiva;
    private javax.swing.JButton btnDetalle;
    private javax.swing.JButton btnEditarA;
    private javax.swing.JButton btnEliminarA;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JButton btnSalir;
    private javax.swing.JComboBox cboxEstado;
    private javax.swing.JComboBox cboxProducto;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblResultadosAlmacen;
    private javax.swing.JTextField txtDescripcion;
    private javax.swing.JTextField txtDireccion;
    // End of variables declaration//GEN-END:variables
}
